package com.recharge.service.httpInterFace;


import com.recharge.domain.context.SpringUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 商户接口号类对应表
 */
@Getter
@AllArgsConstructor
public enum ProviderInterFace {

    OTHER_INTERFACE(0,"未选择系统", null),
    JINGHENG_INTERFACE(1, "敬恒系统", JingHengHTTPImpl.class),
    XINGDAICHONG_INTERFACE(2, "星代充卡密系统(未测试)", XinDaiChongHTTPImpl.class),
    XIAOMA_INTERFACE(3, "小马系统(未测试)", XiaomaHTTPImpl.class),
    YUETU_INTERFACE(4, "月兔系统", YueTuHTTPImpl.class),
    JIUYA_INTERFACE(5, "久雅系统", JiuYaHTTPImpl.class),
    RUIDA_INTERFACE(6, "瑞哒系统", RuiDaHTTPImpl.class),
    SAIPUYOUSI_INTERFACE(7, "赛浦优斯加油卡系统(未测试)", SaiPuYouSiHTTPImpl.class),
    JUDIAN_INTERFACE(8, "聚点话费系统(未测试)", JuDianHTTPImpl.class),
    HONGXING_INTERFACE(9, "鸿兴话费系统", HongXingHTTPImpl.class),
    XIAOSI_INTERFACE(10, "小四话费系统(未对接)", XiaoSiHTTPImpl.class),
    XIAOSI2_INTERFACE(11, "小四(2)话费系统", XiaoSiHttpImpl2.class),
    JIAZHI_INTERFACE(12, "加值话费系统", JiaZhiHTTPImpl.class),
    CHUANGXUN_INTERFACE(13, "创讯话费系统(未测试)", ChuangXunHTTPImpl.class),
    REYI_INTERFACE(14, "广州热意话费系统", ReYiHTTPImpl.class),
    DAOCHUN_INTERFACE(15, "道春话费系统", DaoChunHTTPImpl.class),
    SHENLIN_INTERFACE(16, "森林话费系统(新)", ShenLinHTTPImpl.class),
    GUANGXIAN_INTERFACE(17, "光线充值系统(新-未测试)", GuangXianHTTPImpl.class)
    ;

    /**
     * 接口号
     */
    private int number;
    /**
     * 对接系统名
     */
    private String name;
    /**
     * 类对象
     */
    private Class<?> ClassObj;

    /**
     * 在springboot中获取供应商适配接口类
     *
     * @param number 接口号
     * @return com.recharge.service.httpInterFace.ProviderHTTPService
     */
    public static ProviderHTTPService getHTTPObject(int number) {
        if (number == 0){
            return null;
        }
        ProviderInterFace[] values = ProviderInterFace.values();
        ProviderInterFace providerInterFace = null;
        for (ProviderInterFace value : values) {
            if (number == value.number) {
                providerInterFace = value;
                break;
            }
        }
        if (providerInterFace == null){
            return null;
        }
        try {
            return (ProviderHTTPService)SpringUtil.getBean(providerInterFace.getClassObj());
        } catch (Exception e) {
            System.out.println("查询供应商api接口失败" + e.getMessage());
            return null;
        }

    }
}
